package com.youbug.mall.member_ums.controller;


import com.youbug.common.vo.QueryVo;
import com.youbug.mall.member_ums.entity.UmsMember;
import com.youbug.mall.member_ums.service.IUmsMemberService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;
import com.youbug.common.vo.R;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 会员 前端控制器
 * </p>
 *
 * @author youbug
 * @since 2024-06-17
 */
@RestController
@RequestMapping("/umsMember")
public class UmsMemberController {
@Autowired
private IUmsMemberService umsMemberService;

    @PostMapping("/getUmsMemberPage")
    public R<IPage<UmsMember>> getUmsMemberPage(@RequestBody QueryVo<UmsMember> queryVo){

        IPage<UmsMember> umsMembers = umsMemberService.getUmsMemberPage(queryVo);

        return R.ok(umsMembers);
    }

    @GetMapping("/getUmsMemberById/{id}")
    public R<UmsMember> getUmsMemberById(@PathVariable Integer id){

        UmsMember umsMember = umsMemberService.getById(id);

        return R.ok(umsMember);
    }

    @PostMapping("/add")
    public R<Boolean> add(@RequestBody UmsMember umsMember){

        boolean save = umsMemberService.save(umsMember);

        return  R.ok(save);
    }

    @PostMapping("/update")
    public R<Boolean> update(@RequestBody UmsMember umsMember){

        boolean update = umsMemberService.updateById(umsMember);

        return  R.ok(update);
    }

    @GetMapping("/delete/{id}")
    public R<Boolean> delete(@PathVariable Integer id){

        boolean remove = umsMemberService.removeById(id);

        return  R.ok(remove);
    }

}

